package im.vinci.server.feed.controller;

import im.vinci.server.feed.domain.UserPlayInfo;
import im.vinci.server.feed.domain.UserPlayTimeInfo;
import im.vinci.server.feed.service.VinciPlayListService;
import im.vinci.server.security.ApiSecurityLabel;
import im.vinci.server.utils.apiresp.ResultObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by mingjie on 17/2/14.
 */
@RestController
@RequestMapping(value = "/vinci/playlist", produces = "application/json;charset=UTF-8")
public class VinciPlayListController {

    @Autowired
    private VinciPlayListService vinciPlayListService;

    @RequestMapping(value = "/time/{user_id}", method = RequestMethod.GET)
    @ApiSecurityLabel(isCheckLogin = true)
    public ResultObject<List<UserPlayTimeInfo>> getPlayTimeList(@PathVariable("user_id") long userId, @RequestParam("date") long dateTime) {
        return new ResultObject<>(vinciPlayListService.getPlayTimeList(userId, dateTime));
    }

    @RequestMapping(value = "/{user_id}", method = RequestMethod.GET)
    @ApiSecurityLabel(isCheckLogin = true)
    public ResultObject<UserPlayInfo> getPlayList(@PathVariable("user_id") long userId, @RequestParam("date") long dateTime) {
        return new ResultObject<>(vinciPlayListService.getPlayList(userId, dateTime));
    }
}
